
var type = "12";

function setSecondClass(val){
	var up_class_id = val;
  Ts_categoryInfo.checkCatSonById(up_class_id,function(ret){
    if(ret=="0"){
      $("class_flag").value="0";  	  
  	}
  	else
  	{
  	   $("class_flag").value="1"; 
  	}
  });	
	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort2);
}

function setSort2(map_data) {
 	DWRUtil.removeAllOptions("sort2");
	DWRUtil.addOptions("sort2", map_data);
	$("sort3").style.display = "none";
	var item = $("sort2").length;
	if (item == 0) {
		$("sort2").style.display = "none";
	} else {
		$("sort2").style.display = "block";
	}
}


function setTherdClass(val) { 
 
	var up_class_id = val;
	Ts_categoryInfo.checkCatSonById(up_class_id,function(ret){
  	if(ret=="0")
  	{
      $("class_flag").value="0";  	  
  	}
  	else
  	{
  	   $("class_flag").value="1"; 
  	}
  });	
	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort3);
}
function setSort3(map_data) {
  
	if (map_data != null) {
		DWRUtil.removeAllOptions("sort3");
		DWRUtil.addOptions("sort3", map_data);
		var item = $("sort3").length;
		if (item == 0) {
			$("sort3").style.display = "none";
		} else {
			$("sort3").style.display = "block";
		}
	}
}


function setTypeName1(obj){
	var idx = obj.value;
	$("class_id3").value="";
	$("class_id2").value="";
	$("class_id1").value=idx;
	Ts_categoryInfo.getCatNameById(idx,setClassName1);
}
function setClassName1(val) {
	$("name3").innerHTML = "";
	$("name2").innerHTML = "";
	$("name1").innerHTML = val;
}

function setTypeName2(obj){
	var idx = obj.value;
	$("class_id3").value="";
	$("class_id2").value=idx;
	Ts_categoryInfo.getCatNameById(idx,setClassName2);
}

function setClassName2(val) {
	$("name3").innerHTML = "";
	$("name2").innerHTML = "&nbsp; &gt; " + val + "&nbsp;";
}
function setTypeName3(obj){
	var idx = obj.value;
	Ts_categoryInfo.checkCatSonById(idx,function(ret){
  	if(ret=="0")
  	{
      $("class_flag").value="0";  	  
  	}
  	else
  	{
  	   $("class_flag").value="1"; 
  	}
  });	
	$("class_id3").value=idx;
	Ts_categoryInfo.getCatNameById(idx,setClassName3);

	
}
function setClassName3(val) {
	$("name3").innerHTML = "&nbsp; &gt; " + val + "&nbsp;";
}


function submitValue(){
	
	var class_attr=""; 
	for( var i=1;i<4;i++)
	{
			if( document.getElementById("class_id"+i).value !="")
			{
				class_attr += document.getElementById("class_id"+i).value + "|";	
			}
	}
  
  document.getElementById("class_attr").value =class_attr;

	if(document.getElementById("class_attr").value == "")
	{
     alert( "请选择商机所属类目！" );
		 return;
	}

	
	if(document.getElementById("class_flag").value != "1" )
	{
		//alert( "请选择完整类目！" );
		//return;
	}
	
	var flag_code = document.getElementById("flag_code").value;
	
	if(flag_code == "0")
	{
		window.location.href = "addDetailInfo.jsp?class_attr="+class_attr;
	}
	if(flag_code == "1")
	{
		 var biz_id = document.getElementById("biz_id").value;
		 window.location.href = "updateInfo.jsp?biz_id="+biz_id+"&class_attr="+class_attr;
	}
}  

 
 function setProvince()
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions('province');
		DWRUtil.addOptions('province',{'':'请选择'});
		DWRUtil.addOptions('province',data);
	})
}
function setCitys(prov)
{
   var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions('eparchy_code');
		DWRUtil.addOptions('eparchy_code',{'':'请选择'});
		DWRUtil.addOptions('eparchy_code',data);
		DWRUtil.removeAllOptions('city_code');
		DWRUtil.addOptions('city_code',{'':'请选择'});
	});
}

function setAreas(city_id){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions('city_code');
		DWRUtil.addOptions('city_code',{'':'请选择'});
	 	DWRUtil.addOptions('city_code',data);
	});
}